package listbyorder.access301_400.test384;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Solution {

    int[] nums;
    int[] pres;
    int len;
    List<Integer> indexes;

    public Solution(int[] nums) {
        this.nums = nums;
        this.pres = nums;
        this.len = nums.length;
        this.indexes = new ArrayList<>();
        for (int i = 0; i < this.len; i++) {
            indexes.add(i);
        }
    }

    /**
     * Resets the array to its original configuration and return it.
     */
    public int[] reset() {
        nums = pres;
        return pres;
    }

    /**
     * Returns a random shuffling of the array.
     */
    public int[] shuffle() {
        boolean[] isSite = new boolean[len];
        List<Integer> curs = new ArrayList<>(indexes);
        Collections.shuffle(curs);
        int[] ans = new int[len];
        int index = 0;
        for (Integer cur : curs) {
            ans[cur] = nums[index++];
        }
        return ans;
    }
}
